<!DOCTYPE HTML><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title><? echo $title ?></title>
<? require("lib.php"); ?>
</head>
<body>
  <div class="container-fluid"><!-- Start Content Box -->
	  <div class="row-fluid">
	    <div class="span12">
	     <div class="wedge10px"></div>
	      <ul class="breadcrumb">
	      <li><a href="configuration.php"><?=ROOT_INDEX_PAGE?></a> <span class="divider">/</span></li>
	      <li class="active"><? echo $title ?></li>
	    </ul>

<?
switch ($do) {
	case "update":
	default: update($rows);break;
}
?>
<? function show_box($rows, $iseditmode){
	global $option, $h, $title, $url, $lang, $module, $is_super_user;
	if($iseditmode){
		$info=array();
		$str_tab='<ul class="nav nav-tabs" id="myTab">';
		$str_div='<div class="well"><div class="tab-content">';
		foreach($rows as $row){
			if(is_enabled($row['name'])) {
				$mod=$module->get_row($row['module'],"name");
				$info[$row['module']]['tab']='<li><a href="#'.$row['module'].'" data-toggle="tab">'.$mod['description_'.$lang].'</a></li>';
				$info[$row['module']]['div']='<div class="tab-pane" id="'.$row['module'].'">';
				//$str.="<tr><td colspan='2'><b>".$mod['description_'.$lang]."</b></td></tr>";
			}

			if(! isset($info[$row['module']]['str'])) $info[$row['module']]['str']='';

			// 为需要的字段构造表单项目
			if(is_enabled($row['name'])){
				
				$info[$row['module']]['str'].='<div><label>'.$row['tip_'.$lang].'</label>';
				if($row['type']==7){ 
					$info[$row['module']]['str'].=$h->textarea('id_'.$row['id'], d($row['value']),16,3,'span8');
				}
				else {
					if($row['id']==73) $info[$row['module']]['str'].=$h->password('id_'.$row['id'], d($row['value']),'span8');
					else $info[$row['module']]['str'].=$h->text('id_'.$row['id'], d($row['value']),'span8');
				}

				$tem_check=0;
				if($row['is_enabled']) $tem_check=1;
				// 超级管理员
				if($is_super_user)
				$info[$row['module']]['str'].=' &nbsp; '.$h->checkbox('check_'.$row['id'],$tem_check).' 启用';
				// for GPS
				if($row['id']==39) $info[$row['module']]['str'].=' &nbsp; ('.ROOT_NOTE.': <a href="http://api.map.baidu.com/lbsapi/getpoint/" target="_blank">'.ROOT_COORDINATE_LINK.'</a>)';
				$info[$row['module']]['str'].='</div>';
			}
		}
		foreach($info as $val){
			$str_tab.=$val['tab'];
			$str_div.=$val['div'].$val['str'].'</div>';
		}
		$str_tab.='</ul>';
		$str_div.='</div></div>';
?>
	<div>
		<? echo $str_tab.$str_div ?>
		<script>
		  $(function () {
		    $('#myTab a[href=#site]').tab('show');
		  })
</script>
	</div>
		<div class="form-actions">
            <? echo $h->submit('save', '&nbsp; '.ROOT_SAVE.'&nbsp;', $iseditmode==1?' btn btn-primary ':'hide') ?> &nbsp; &nbsp; <a onClick="history.go(-1)">[ <?=ROOT_CANCEL?> ]</a>
        </div>    
    <?  }
    else {
      	$str='';
		$last_header="";
      	foreach($rows as $row){
			if(is_enabled($row['name'])&&$last_header!=$row['module']){
				$mod=$module->get_row($row['module'],"name");
				$str.="<tr><td colspan='2'><b>".$mod['description_'.$lang]."</b></td></tr>";
			}
			$last_header=$row['module'];
			if(is_enabled($row['name']))$str.='<tr>';
			else $str.='<tr class="hide">';
      		$str.='<td class="l">'.$row['tip_'.$lang].'</td><td>'.d($row['value']).'</td></tr>';
      	}
    	?>
	<table width="99%" cellspacing="0" cellpadding="3" class="mbox set">
      <tr class="th"><td class="thtitle"  width="240" align="right"><? echo $title ?></td><td align="right"><input value="<?php echo decode($row["id"]) ?>" name="id" type="hidden"></td></tr>
      <? echo $str; ?>
      <tr><td class="l">&nbsp;</td><td><br><a href="<? echo $url ?>.php?do=update">[ <?=ROOT_EDIT_SETTING?> ]</a><br><br></td></tr>
    </table>
	<?
}
	} ?>
 <br class="clear" />
	</div> <!-- End .content-box-content -->
    <br class="clear" />
</div><!-- End .content-box -->
</body>
</html>